package dao;

import java.util.List;

import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import entity.ModeTransport;


@Stateless
@Local
public class ModeTransportDaoJpa implements ModeTransportDao {

	private EntityManager entityManager;
	
	@PersistenceContext(unitName="MyPersistentUnit")
	public void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}

	public EntityManager getEntityManager() {
		return entityManager;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<ModeTransport> getAllModeTransports() {
		Query query = entityManager.createQuery("select m from ModeTransport as m");
		List<ModeTransport> listeModeTransport = query.getResultList();
		return listeModeTransport;
	}
	
	


}
